package com.tbh.ioc.scope;

import com.tbh.ioc.bean.HelloWorld;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class PrototypeMain {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("Beans.xml");
        HelloWorld helloWorld = (HelloWorld) applicationContext.getBean("prototypeExample");
        helloWorld.setMessage("ApplicationContext getBean");
        String message = helloWorld.getMessage();
        System.out.println(message);

        HelloWorld helloWorld2 = (HelloWorld) applicationContext.getBean("prototypeExample");
        String message2 = helloWorld2.getMessage();
        System.out.println(message2);

        // 分别获取singletonExample，打印的结果是不一样，可见获取的不是同一个Bean
    }
}
